package io.renren.modules.app.controller;

import io.renren.common.utils.ResponseModel;
import io.renren.modules.app.annotation.Login;
import io.renren.modules.nfy.entity.ProductEntity;
import io.renren.modules.nfy.service.ProductService;
import io.renren.modules.sys.entity.SysDictionaryEntity;
import io.renren.modules.sys.entity.XmlxEntity;
import io.renren.modules.sys.service.SysDictionaryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("/app/common")
@Api(tags = "app-常用接口")
public class AppCommonController {
    @Autowired
    private SysDictionaryService sysDictionaryService;
    @Autowired
    private ProductService productService;

    @Login
    @PostMapping("dictionary")
    @ApiOperation("app查询字典")
    public ResponseModel<List<SysDictionaryEntity>> dictionary(@RequestBody SysDictionaryEntity sysDictionary) {
        List<SysDictionaryEntity> list = sysDictionaryService.loadDictionary(sysDictionary);
        return ResponseModel.of(list);
    }

    @GetMapping("/detail/{id}")
    @ApiOperation("宁封窑产品-详情")
    public ResponseModel<ProductEntity> getProductDetail(@PathVariable("id") Long id) {
        ProductEntity product = productService.getById(id);
        return ResponseModel.of(product);
    }
}
